import os
from google.appengine.ext.webapp import template

def render_header(response, request, data):
    menu = []
    menu.append(header_menu_add_item('Home', '/'));
    menu.append(header_menu_add_item('Downloads', '/downloads'));
    menu.append(header_menu_add_item('Highscore', '/highscore'));
    menu.append(header_menu_add_item('Maps', '/maps'));
    
    for i, v in enumerate(menu):
        if menu[i]['url'] == request.path:
            menu[i]['active'] = 'active'
            
    data['menu'] = menu
    path = os.path.join(os.path.join(os.path.dirname(__file__), 'templates'), 'header.tpl.html')
    response.out.write(template.render(path, data));
    
def header_menu_add_item(text, url):
    return {
            'text': text,
            'url': url,
            'active': ''
        }